package Java.com;

public class VarargsDemo {
	public static void main(String[] args) {
		// 使用变量参数调用方法
		printMax(314, 321, 213, 212, 356.5);
		printMax(new double[] { 1, 2, 3 });
	}

	public static void printMax(double... numbers) {
		if (numbers.length == 0) {
			System.out.println("No argument passed!");
			return;
		}
		double result = numbers[0];
		for (int i = 1; i < numbers.length; i++)
			if (numbers[i] > result)
				result = numbers[i];
		System.out.println("参数列表中最大值是：" + result);
	}
}
